﻿using System.Collections;
using System.Collections.Generic;
using BearUtil.Hidden;
using Sirenix.OdinInspector;
using UnityEngine;
namespace BearUtil
{
	[CreateNodeMenu("自定义节点/场景台词"), Title("场景台词")]
	public class ScenesLines : BearNode
	{
		[LabelText("节点类型"), HideInInspector]
		public int type = 23;
		[SerializeField, HideLabel, ValueDropdown("GetActors"), OnValueChanged("setRoleId")]
		public ActorData _actor;
		private ActorData[] GetActors()
		{
			var storyGraph = ((graph as DialogGraph)?.owner.graph as StoryGraph);
			if (storyGraph != null)
			{
				var series = StoriesSetting.Instance.FindSeriesByStoryGraph(storyGraph);
				return series.Actors.ToArray();
			}
			return new ActorData[0];
		}

		public int role_id;
		private void setRoleId(ActorData actor)
		{
			role_id = _actor.role_id;
		}
		[LabelText("文本 id"), ValueDropdown("GetLineKey", DropdownWidth = 300), OnValueChanged("switchContent")]
		public string lines;
		[HideLabel, TextArea, Sirenix.OdinInspector.ReadOnly]
		public string _content;
		private List<string> GetLineKey()
		{
			return  LanguageCtrl.Instance.Langs;
		}
		private void switchContent(string lineKey)
		{
			_content = LanguageCtrl.Instance.GetLineContent(lineKey);
		}
		[HideLabel, ValueDropdown("GetAudioClip", DropdownWidth = 300), OnValueChanged("SetValue")]
		public AudioClip audio;
		[LabelText("音频"), HideInInspector]
		public string voice;
		public void SetValue(AudioClip clip) => voice = clip.name;
		public List<AudioClip> GetAudioClip() { return AudioCtrl.Instance.Clips;}
	}
}
